import { FrontendSession, MsgHandler } from "kilom";
import { msgId } from "../../../cfg/msgcfg";

export default class MsgConnectorMain extends MsgHandler {

    async join(sess: FrontendSession, msg: { name: string }) {
        let res = await this.app.rpc("game").game.main.join(this.app.svr.id, msg.name);
        if (res.err) {
            sess.send(msgId.join, { err: "加入失败:" + res.err.msg });
            return;
        }
        sess.bind(res.data.uid);
        sess.set({ name: msg.name });
        sess.send(msgId.join, res.data);
    }

}